/**
 *  iBizSys 5.0 机器人生产代码（不要直接修改当前代码）
 *  http://www.ibizsys.net
 */
package com.sa.litetwo.app.card.ctrlhandler;


import java.util.ArrayList;
import java.util.List;
import net.ibizsys.paas.util.StringHelper;
import net.ibizsys.paas.web.WebContext;
import net.ibizsys.paas.demodel.DEModelGlobal;
import net.ibizsys.paas.demodel.IDataEntityModel;
import net.ibizsys.paas.service.IService;
import net.ibizsys.paas.service.ServiceGlobal;

import com.sa.litetwo.app.srv.card.ctrlmodel.GG_CERTIFMainGridModel;
import com.sa.litetwo.srv.card.demodel.GG_CERTIFDEModel;
import com.sa.litetwo.srv.card.service.GG_CERTIFService;
import com.sa.litetwo.srv.card.dao.GG_CERTIFDAO;
import com.sa.litetwo.srv.card.entity.GG_CERTIF;

import net.ibizsys.paas.core.DEDataSetFetchContext;
import net.ibizsys.paas.ctrlmodel.IGridModel;
import net.ibizsys.paas.db.DBFetchResult;
import net.ibizsys.paas.web.AjaxActionResult;
import net.ibizsys.paas.web.MDAjaxActionResult;
import net.ibizsys.paas.entity.IEntity;
import net.ibizsys.paas.sysmodel.ISystemRuntime;
import net.ibizsys.paas.ctrlhandler.IGridEditItemHandler;
import net.ibizsys.paas.ctrlhandler.IGridEditItemUpdateHandler;

/**
 * 应用视图[GG_CERTIFGridView]表格[grid]后台处理对象基类
 */
public class GG_CERTIFGridViewGridHandler extends net.ibizsys.paas.ctrlhandler.GridHandlerBase{

    protected GG_CERTIFMainGridModel gridModel = null;
    public GG_CERTIFGridViewGridHandler()  {
        super();
    }

    /* (non-Javadoc)
     * @see net.ibizsys.paas.ctrlhandler.CtrlHandlerBase#onInit()
     */ 
     @Override
    protected void onInit() throws Exception
    {
         this.setMinorSortField("KSSJ");
    	 this.setMinorSortDir("DESC");
        gridModel = (GG_CERTIFMainGridModel)this.getViewController().getCtrlModel("grid");
    	super.onInit();
    	

    }
       /* (non-Javadoc)
        * @see net.ibizsys.paas.ctrlhandler.GridHandlerBase#getGridModel()
        */
       @Override
	protected IGridModel getGridModel()
	{
		return this.getRealGridModel();
	}
    
    /**
     * 获取实际的表格模型对象
     * @return
     */  
    protected GG_CERTIFMainGridModel getRealGridModel(){
    	return this.gridModel;
    }

    /**
     * 获取实际的实体服务对象
     * @return
     */
       protected GG_CERTIFService getRealService(){
            return (GG_CERTIFService)this.getService();
       }

       /**
	 * 准备部件操作数据访问能力
	 * @throws Exception
	 */
        @Override
	protected void prepareDataAccessActions()throws Exception
	{
              super.prepareDataAccessActions();
             this.registerDataAccessAction("update","UPDATE");
             this.registerDataAccessAction("remove","DELETE");
             this.registerDataAccessAction("loaddraft","CREATE");
             this.registerDataAccessAction("load","READ");
             this.registerDataAccessAction("create","CREATE");
         }

    /* (non-Javadoc)
     * @see net.ibizsys.paas.ctrlhandler.MDCtrlHandlerBase#fetchDEDataSet(net.ibizsys.paas.core.DEDataSetFetchContext)
     */

      @Override
	protected DBFetchResult fetchDEDataSet(DEDataSetFetchContext deDataSetFetchContext) throws Exception
	{
	     return  this.getRealService().fetchDefault(deDataSetFetchContext);
	}

    /* (non-Javadoc)
     * @see net.ibizsys.paas.ctrlhandler.MDCtrlHandlerBase#getDraftEntity()
     */ 
    @Override
    protected IEntity getDraftEntity()throws Exception
    {
    	GG_CERTIF entity = new GG_CERTIF();
        getDraftEntity(entity);
        return entity;
    }

    /**
     * 获取操作数据对象
     * @param entity
     * @throws Exception
     */ 
    protected void getDraftEntity(GG_CERTIF entity)throws Exception
    {
    	this.getRealService().executeAction(GG_CERTIFService.ACTION_GETDRAFT,entity);
    }

    /* (non-Javadoc)
     * @see net.ibizsys.paas.ctrlhandler.MDCtrlHandlerBase#getEntity(java.lang.Object)
     */
    @Override
    protected IEntity getEntity(Object objKeyValue)throws Exception
    {
    	GG_CERTIF entity = new GG_CERTIF();
        entity.set(GG_CERTIF.FIELD_GG_CERTIFID,objKeyValue);
        this.getRealService().executeAction(GG_CERTIFService.ACTION_GET,entity);
        return entity;
    }


    /* (non-Javadoc)
     * @see net.ibizsys.paas.ctrlhandler.MDCtrlHandlerBase#createEntity(net.ibizsys.paas.entity.IEntity)
     */
    @Override
    protected IEntity createEntity(IEntity iEntity)throws Exception
    {
        this.getRealService().executeAction(GG_CERTIFService.ACTION_CREATE,iEntity);
        return iEntity;
    }

    /* (non-Javadoc)
     * @see net.ibizsys.paas.ctrlhandler.MDCtrlHandlerBase#updateEntity(net.ibizsys.paas.entity.IEntity)
     */
    @Override
    protected IEntity updateEntity(IEntity iEntity)throws Exception
    {
        this.getRealService().executeAction(GG_CERTIFService.ACTION_UPDATE,iEntity);
        return iEntity;
    }

    /* (non-Javadoc)
     * @see net.ibizsys.paas.ctrlhandler.MDCtrlHandlerBase#removeEntity(java.lang.Object)
     */
    @Override
    protected void removeEntity(Object objKeyValue)throws Exception
    {
    	GG_CERTIF entity = new GG_CERTIF();
        entity.set(GG_CERTIF.FIELD_GG_CERTIFID,objKeyValue);
        this.getRealService().executeAction(GG_CERTIFService.ACTION_REMOVE,entity);
    }



}